﻿/**
 * ...
 * @author 
 */

 
package racingGame.ui 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import racingGame.events.ScreenEvent;

	
	public class MainMenu extends MovieClip implements IStackableScreen
	{
		/**** Private Variables ****/
		
		private var _view 		:MainMenuAsset;
		private var _play		:MovieClip;
		private var _enabled	:Boolean;
		
		
		
		/**** Public Methods ****/
		
		/**
		 * Constructor.
		 */
		public function MainMenu() 
		{
			super();
			_view = new MainMenuAsset();
			addChild(_view);
			_play = _view.getChildByName("play_btn") as MovieClip;
			_play.buttonMode = true;
			_play.mouseChildren = false;
		}
		
		
		/**
		 * Retrieves the enables status.
		 */
		public function get isEnabled() :Boolean
		{
			return _enabled;
		}
		
		
		/**
		 * Enable this screen.
		 */
		public function enable() :void
		{
			_enabled = true;
			_play.addEventListener(MouseEvent.CLICK, onPlayClick);
			this.visible = _enabled;
		}
		
		
		/**
		 * Disable this screen.
		 */
		public function disable() :void
		{
			_enabled = false;
			_play.removeEventListener(MouseEvent.CLICK, onPlayClick);
			this.visible = _enabled;
		}
		
		
		/**** Callback Methods ****/
		
		/**
		 * Handle the click on the Play Button. Goes to the Help menu.
		 * 
		 * @param	e	The click event.
		 */
		private function onPlayClick(e :MouseEvent):void 
		{
			dispatchEvent(new ScreenEvent(ScreenEvent.SCREEN_EXIT, Help));
		}
		
	}

}